﻿<include file='Public:header' />
<link rel='stylesheet' href='__APP__/Public/js/kindeditor/themes/default/default.css'
    type='text/css'>
<script type="text/javascript" src="__APP__/Public/js/kindeditor/kindeditor-min.js"></script>
<script type="text/javascript" src="__APP__/Public/js/kindeditor/zh_CN.js"></script>
<style>
    .picture
    {
        display: inline-block;
        width: 600px;
    }
    .picture li
    {
        list-style-type: none;
        width: 350px;
    }
</style>
<div class="container02">
    <div class="main">
        <div class="left">
            <br />
            <div class="piclist">
                <div class="right">
                    <input id='uid' type='hidden' value='{$uid}' />
		    		<input type="button" value="{$Think.lang.goback}" onclick="goback('/Users/userProfile/uid/{$uid}');"/>
					<input type="button" id="J_selectImage"   value="批量上传" /> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                </div>
                <div style="clear: both">
                </div>
                <br />
                <ul id='J_imageView'>
                    
                    <li>
                     
                    </li>
                </ul>
                <div style="clear: both">
                </div>

            </div>
        </div>
        <div style="clear: both">
        </div>
    </div>
</div>
<script>
    KindEditor.ready(function (K) {
        var editor = K.editor({
            uploadJson: '__APP__/Public/js/kindeditor/php/upload_json.php',
            allowFileManager: true
        });
        K('#J_selectImage').click(function () {
            editor.loadPlugin('multiimage', function () {
                editor.plugin.multiImageDialog({
                    clickFn: function (urlList) {
                        var imgNames = '';
                        K.each(urlList, function (i, data) {
                            imgNames = imgNames + data.url + ',';
                        });
                        imgNames.substring(0, imgNames.length - 1);
                        insertPicture(imgNames);

                        editor.hideDialog();
                    }
                });
            });
        });

        loadPicture(1);
    });


    function insertPicture(imgNames) {
        var uid = $('#uid').val();

        $.post('/Users/insertPicture', { uid: uid, imgNames: imgNames }, function (data) {
            var obj = $.parseJSON(data);
            var result = obj.status;

            if (result == 0) {
                alert('{$Think.lang.pls_enter_basic_info}');
            } else if (result == 1) {
                alert('{$Think.lang.pls_upload_img}');
            } else if (result == 2) {
                //alert('{$Think.lang.add_success}');
                $('#J_imageView').html('');
                loadPicture(1);
            } else if (result == 3) {
                alert('{$Think.lang.add_failed}');
            }
        });
    }



    function delPic(pid) {
        $.post('/Users/delPic', { pid: pid }, function (data) {
            var obj = $.parseJSON(data);
            if (obj.status == 1) {
                clearDiv();
                loadPicture(1);
            } else {
                alert(obj.msg);
            }
        });
    }
    function clearDiv() {
        $('#J_imageView').html('');
    }
</script>
<include file='Public:footer' />
